<template>
   <homePannel title="新鲜好物" subTitle="新鲜出炉 品质靠谱">
     <!-- 右侧 -->
     <template #right>
         <xtx-more></xtx-more>
     </template>
        <!-- 主体 -->
       <template #main>
         <ul ref="pannel" class="goods-list">
          <li v-for="item in newList" :key="item.id">
           <RouterLink :to="`/good/${item.id}`">
            <img  v-img-lazy="item.picture" alt="" />
            <p class="name">{{ item.name }}</p>
            <p class="price">&yen;{{ item.price }}</p>
          </RouterLink>
        </li>
      </ul>
       </template>
   </homePannel>
</template>

<script>
import homePannel from './home-pannel.vue'
import { findNew } from '@/api/home'
import { ref } from 'vue'
export default {
  components: {
    homePannel
  },
  setup () {
    const newList = ref([]) // 存储数据
    async function getNewList () { // 执行函数
      const res = await findNew() // 调用接口
      newList.value = res.data.result // 赋值
    }
    getNewList() // 调用函数 执行
    return { newList }
  }
}
</script>

<style scoped lang='less'>
.goods-list {
  display: flex;
  justify-content: space-between;
  height: 406px;
  li {
    width: 306px;
    height: 406px;
    background: #f0f9f4;
    img {
      width: 306px;
      height: 306px;
    }
    p {
      font-size: 22px;
      padding-top: 12px;
      text-align: center;
      text-overflow: ellipsis;
      overflow: hidden;
      white-space: nowrap;
    }
    .price {
      color: @priceColor;
    }
  }
}
</style>
